import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) {
       String reg = "([a-zA-Z0-9]+){6,20}";
       System.out.println( validRegexp("hdad",reg) );
       System.out.println( validRegexp("hdhdffsdfsdfsdfsd",reg) );
       System.out.println( validRegexp("hdhdfhk",reg) );
       System.out.println( validRegexp("asdASD123",reg) );
       System.out.println( validRegexp("sdaAS%#$545",reg) );
       

    }
    private static boolean validRegexp(final String text, final String pattern) {
        final Pattern compile = Pattern.compile(pattern);
        final Matcher matcher = compile.matcher(text);
        return matcher.matches();
    }

}
